package com.yxy.controller.app;


import com.yxy.common.ServerResponse;
import com.yxy.controller.service.ClientContentController;
import com.yxy.dto.ClientContentModel;
import com.yxy.entity.ClientContent;
import com.yxy.service.ClientContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/app/appContent/")
public class AppContentController {

    @Autowired
    private ClientContentService clientContentService;

    @RequestMapping(value = "bannerList", method = RequestMethod.GET)
    @ResponseBody
    public ServerResponse<List<ClientContentModel>> list() throws Exception{

        List<ClientContent> clientContentList = clientContentService.findAll();
        List<ClientContentModel> clientContentModels= new ArrayList<ClientContentModel>();
        if(clientContentList!=null && clientContentList.size()>0){
            for (ClientContent clientContent:clientContentList) {
                ClientContentModel clientContentModel = new ClientContentController().entityToModel(clientContent);
                clientContentModels.add(clientContentModel);
            }
        }
        return ServerResponse.createBySuccess("查询成功",clientContentModels);
    }

}
